//
//  ZyaAddressSegVC.swift
//  SlaughterClient
//
//  Created by 邱仙凯 on 2021/8/18.
//  Copyright © 2021 zwb. All rights reserved.
//

import UIKit
 
class ZyaAddressSegVC: DQBaseHomeViewController {
    
    
    fileprivate let vc1: ZyaClientAddressController = {
        let v = ZyaClientAddressController(type: .recive)
        v.title = "收货地址"
        return v
    }()
    fileprivate let vc2: ZyaClientAddressController = {
        let v = ZyaClientAddressController(type: .send)
        v.title = "发货地址"
        return v
    }()
    var typeX:ZyaCAddrType = .recive

    override func viewDidLoad() {
        super.viewDidLoad()
        title = "地址管理"
        self.DQColer = Theme.primaryColor()
        
       
        self.addChild(vc1)
        self.addChild(vc2)
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "新增地址", style: .done, target: self, action: #selector(addAddress))
        
    }
    
    override func selectedTitle(title: String) {
        self.typeX = title == "收货地址" ? .recive : .send
     }
    
    @objc func addAddress() {
        let vc = ZyaAddressFormVC(type: self.typeX)
        vc.refreshClosure = {
            self.vc1.tableView.mj_header?.beginRefreshing()
            self.vc2.tableView.mj_header?.beginRefreshing()

        }
        vc.title = "新增" + (self.typeX == .recive ? "收货地址" : "发货地址")
        self.navigationController?.pushViewController(vc, animated: true)
    }
   
    
    
    
}
